package cn.webrx;

import java.io.Console;
import java.util.Scanner;

public class Input2 {
    public static void main(String[] args) {
        Console c = System.console();
        String name = "";
        String pwd = "";
        if (c == null) {
            Scanner sc = new Scanner(System.in);
            System.out.print("请输入姓名：");
            name = sc.nextLine();
            System.out.printf("欢迎：%s%n", name);

            System.out.print("请输入密码：");
            pwd = sc.nextLine();
            System.out.println("你的密码是：" + pwd);
        } else {

            //System.out.println(c);
            name = c.readLine("请输入姓名：");
            System.out.printf("欢迎：%s%n", name);

            pwd = new String(c.readPassword("请输入密码："));
            System.out.println("你的密码是：" + pwd);
        }

        System.out.println("---------------------------");
        System.out.println(name);
        System.out.println(pwd);
    }
}
